<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description('Test that the browser doesn\'t crash for lots of Set-Cookies in a WebSocket handshake.');

window.jsTestIsAsync = true;

var ws = new WebSocket('ws://127.0.0.1:8880/cookie-flood');

ws.onopen = function () {
    debug('A WebSocket connection is opened.');
};
ws.onmessage = function (e) {
    debug('FAIL: Unexpected onmessage invocation.');
    finishJSTest();
};
ws.onclose = function (e) {
    debug('A WebSocket connection is closed.');
    window.wasClean = e.wasClean;
    shouldBeTrue('wasClean');
    finishJSTest();
};
ws.onerror = function () {
    debug('FAIL: A WebSocket connection has an error.');
    finishJSTest();
};
</script>
</body>
</html>
